package com.kyrie.dataSync;

import com.alibaba.druid.filter.FilterEventAdapter;
import com.alibaba.druid.proxy.jdbc.StatementProxy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/***
 * 描述: sql拦截器，拦截sql同步数据库数据&sql监控
 *
 * @author wuxiang
 * @date 2020-04-28 14:59
 */
public class SQLFilter extends FilterEventAdapter {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    protected void statementExecuteBefore(StatementProxy statement, String sql) {
        logger.info("statement:{},sql:{}",statement,sql);
        super.statementExecuteBefore(statement, sql);
    }

    @Override
    protected void statementExecuteAfter(StatementProxy statement, String sql, boolean result) {
        logger.info("statement:{},sql:{},result:{}",statement,sql,result);
        super.statementExecuteAfter(statement, sql, result);
    }

    @Override
    protected void statementExecuteBatchAfter(StatementProxy statement, int[] result) {
        logger.info("statement:{},result:{}",statement,result);
        super.statementExecuteBatchAfter(statement, result);
    }

    @Override
    protected void statementExecuteUpdateBefore(StatementProxy statement, String sql) {
        logger.info("statement:{},sql:{}",statement,sql);
        super.statementExecuteUpdateBefore(statement, sql);
    }

    @Override
    protected void statementExecuteUpdateAfter(StatementProxy statement, String sql, int updateCount) {
        logger.info("statement:{},sql:{},updateCount:{}",statement,sql,updateCount);
        super.statementExecuteUpdateAfter(statement, sql, updateCount);
    }


}
